package pl.enigmatic.parser.markup;

import pl.enigmatic.parser.xml.Parser;
import pl.enigmatic.parser.xml.ParsingInfo;
import pl.enigmatic.parser.xml.XMLParserExtension;


public class IncludeExtension extends BasicMarkupExtension {

	public static final IncludeExtension instance = new IncludeExtension();

	private IncludeExtension() {
		super("Include");
	}

	@Override
	public boolean parse(final Object target, final MarkupProperties props, final ParsingInfo<?> info, final XMLParserExtension handler) {
		return handler.setParsedProperty(target, info, createInstance(props, info));
	}

	@Override
	public Object createInstance(MarkupProperties props, ParsingInfo<?> info) {
		return Parser.parseXML(info.getStaticInfo().getPath().getAbsolutePath(props.getMainValue()));
	}

}
